package com.lcb.manager.vo;

import com.alibaba.fastjson.JSON;
import com.lcb.manager.entity.Project;

import java.text.SimpleDateFormat;
import java.util.List;

public class ProjectVo {

    private Integer id;

    private String date;

    private String title;

    private String content;

    private List<String> pictures;

    private int index;

    private String info;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getDate() {
        return date;
    }

    public void setDate(String date) {
        this.date = date;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public List<String> getPictures() {
        return pictures;
    }

    public void setPictures(List<String> pictures) {
        this.pictures = pictures;
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }

    public String getInfo() {
        return info;
    }

    public void setInfo(String info) {
        this.info = info;
    }

    public static ProjectVo fromEntity(Project project) {
        if (project == null) return null;
        ProjectVo projectVo = new ProjectVo();
        projectVo.id = project.getId();
        SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
        projectVo.date = sdf1.format(project.getDate());
        projectVo.title = project.getTitle();
        projectVo.content = project.getContent();
        projectVo.pictures = JSON.parseArray(project.getPictures(), String.class);

        return projectVo;
    }
}
